package mya.mes.mdc.logic.utils;

import mya.mes.mdc.model.alarm.MdcAlarm;
import mya.mes.mdc.model.alarm.MdcAlarmHis;
import mya.mes.mdc.model.status.MdcStatus;
import mya.mes.mdc.model.status.MdcStatusHis;

public class HisBuilder {


    public static MdcStatusHis from(MdcStatus status) {

        if (status == null) {
            return null;
        }
        MdcStatusHis his = new MdcStatusHis();

        BeanCopy.copySrcToDest(status, his);

        return his;
    }

    public static MdcAlarmHis from(MdcAlarm alarm) {
        if (alarm == null) {
            return null;
        }
        MdcAlarmHis his = new MdcAlarmHis();
        BeanCopy.copySrcToDest(alarm, his);
        return his;
    }

    public static Object from(MdcAlarm alarm,int tableIndex) {
        if (alarm == null) {
            return null;
        }
        Class cla = null;
        Object instance = null;
        try {
            cla = Class.forName("mya.mes.mdc.model.alarm.MdcAlarmHis_"+tableIndex);
            instance = cla.newInstance();
        } catch (ClassNotFoundException e) {

        } catch (InstantiationException e) {

        } catch (IllegalAccessException e) {

        }
        BeanCopy.copySrcToDest(alarm, instance);
        return instance;
    }


}
